<template>
  <div id= "main" class="h-100 w-100" style="min-height: 100vh"></div>
</template>

<script>
import WordCloud from "@/tools/word-cloud.js"
export default {
    name:"HomeType",
    data(){
        return{
            //调用WordCloud对象init()函数，返回的图表对象
            chart:null,
            tags:[],
        };
    },
    async mounted(){
        await this.getTagGroup();
        this.initCharts();
    },
    methods:{
        async getTagGroup(){
            await this.$axios.get("/api/home/tag/group").then((response) => {
                let data = response.data;
                if (data.code ==200){
                    this.tags = data.data;
                }
            });
        },
        //初始化图表
        initCharts(){
            let w = new WordCloud();
           this.chart = w.init("main",this.tags,this.tolist);
        },
        tolist(dataOption){
           let data = dataOption.data;
           console.log(data.name);
        }
    }
}
</script>

<style>

</style>